package com.lj.tools.response;

import lombok.Data;

@Data
public class Result {
    private Integer code = 0;
    private String message;
    private Object data;

    public Result(Integer code, String message, Object data){
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static  Result ok(){
        return new Result(0, "", null);
    }

    public static  Result error(){
        return new Result(400, "", null);
    }

    public Result setContent(String message, Object data){
        this.setMessage(message);
        this.setData(data);
        return this;
    }
    public Result setContent(String message){
        this.setMessage(message);
        return this;
    }

    public Result message(String message){
        this.setMessage(message);
        return this;
    }

    public Result data(Object data){
        this.setData(data);
        return this;
    }

    public Result code(Integer code){
        this.setCode(code);
        return this;
    }


    public static  Result ok(Object data){
        return new Result(0, "", data);
    }

    public static Result error(String message){
        return new Result(400, message, null);
    }

}
